use gee.dta,clear
drop if (year < 1995 | year > 2015)
set scheme s2nomo
*data description，table1
	local varlist "indus eco7w eco13 eco1 city15 env65 env24 env59 env93 yr_sch_sec hf_efiscore"
tabstat env38  wbgi_gee `varlist', s(n mean median sd min max) f(%10.4f)  c(s)

*basic regression  table2
egen id = group(countrycode)
xtset id year
local varlist "eco7w eco13 eco1 city15 env65 env24 env59 env93 yr_sch_sec hf_efiscore"
reg env38  wbgi_gee   // 186 96-14
est store OLS1
reg env38  wbgi_gee `varlist' // 115 96-14
est store OLS2
local varlist "eco7w eco13 eco1 city15 env65 env24 env59 env93 yr_sch_sec hf_efiscore"
xtreg env38 wbgi_gee   `varlist',fe 
est store fe1
xtreg env38 wbgi_gee   `varlist',re 
est store re1
xtreg env38 wbgi_gee  i.year `varlist',fe // 115 96-14
est store fe2
local varlist "eco7w eco13 eco1 city15 env65 env24 env59 env93 yr_sch_sec hf_efiscore"
xtreg env38 wbgi_gee  i.year `varlist',re // 115 96-14
est store re2

esttab OLS1 OLS2  fe1 re1 fe2 re2 ,compress nogap  s(N r2  F ) ///
          star(* 0.1 ** 0.05 *** 0.01)   b(%6.4f)
		  
		  
* regime type ,
	*figure 1

gen dem=1 if ht_regtype1 ==100
replace dem=0 if (ht_regtype==1 | ht_regtype==2 | ht_regtype==3 |  ht_regtype==4 |ht_regtype==99)

twoway ( scatter env38 wbgi_gee if dem ==1 ,msize(0.2) msymbol(O) color(maroon) )(lfit env38 wbgi_gee if dem==1, color(red)) ( scatter env38 wbgi_gee if dem !=1 ,msize(0.2) msymbol(T) color(gray))(lfit env38 wbgi_gee if dem !=1, color(blue))

set scheme s2mono
twoway ( scatter env38 wbgi_gee if dem ==1 ,msize(0.2) msymbol(O) )(lfit env38 wbgi_gee if dem==1 )
twoway  ( scatter env38 wbgi_gee if dem !=1 ,msize(0.2) msymbol(T))(lfit env38 wbgi_gee if dem !=1)

	*table3
	drop inter2
gen inter2 = dem*wbgi_gee
	local varlist "  eco7w eco13 eco1 city15 env65 env24 env59 env93 yr_sch_sec hf_efiscore "  
	reg env38 wbgi_gee  dem
   est store OLS1
   reg env38 wbgi_gee dem inter2
   est store OLS2
   reg env38 wbgi_gee  dem `varlist'
   est store OLS3
   reg env38 wbgi_gee dem inter2 `varlist'
   est store OLS4
   xtreg env38 wbgi_gee dem `varlist' ,fe // 113 96-14
   est store fe1
   xtreg env38 wbgi_gee  dem inter2 `varlist' , fe // 113 03-14
   est store fe2
    xtreg env38 wbgi_gee dem `varlist' i.year ,fe // 113 96-14
   est store fe3
   xtreg env38 wbgi_gee  dem inter2 `varlist' i.year, fe // 113 03-14
   est store fe4
  
   esttab  OLS1 OLS2 OLS3 OLS4 fe1 fe2 fe3 fe4,  label ///
    compress nogap  s(N r2  F)  ///
          star(* 0.1 ** 0.05 *** 0.01)  b(%6.4f)
	
 esttab  OLS1 OLS2  fe1 fe2 ,  label ///
    compress nogap  s(N r2  F)  ///
          star(* 0.1 ** 0.05 *** 0.01)  
		  
* different income level
	* figure2 
twoway ( scatter env38 wbgi_gee if incomelev2 ==1 ,msize(0.2) color(maroon) ) (qfit env38 wbgi_gee if incomelev2 ==1 ,color(red)) ( scatter env38 wbgi_gee if incomelev2 !=1 ,msize(0.2) color(  gray  ))(qfit env38 wbgi_gee if incomelev2 !=1 ,color(blue))

set scheme s2mono
twoway ( scatter env38 wbgi_gee if incomelev2 ==1 ,msize(0.2) ) (qfit env38 wbgi_gee if incomelev2 ==1 )
twoway ( scatter env38 wbgi_gee if incomelev2 !=1 ,msize(0.2) )(qfit env38 wbgi_gee if incomelev2 !=1 )


	* table4
	replace incomelev2 = 0 if incomelev2 ==.
		drop inter
		gen inter = incomelev2 * wbgi_gee
	local varlist "  eco1  city15 env65  env59 env93 yr_sch_sec "  
   reg env38 wbgi_gee  incomelev2,nocons
   est store OLS2
   reg env38 wbgi_gee incomelev2 inter,nocons
   est store OLS3
   reg env38 wbgi_gee  incomelev2 `varlist',nocons
   est store OLS4
   reg env38 wbgi_gee incomelev2 inter `varlist',nocons
   est store OLS5
   xtreg env38 wbgi_gee incomelev2 `varlist' , mle nocons // 113 96-14
   est store fe1
   xtreg env38 wbgi_gee  incomelev2 inter `varlist' , mle nocons // 113 03-14
   est store re
  
   esttab  OLS2 OLS3   fe1 re ,  label ///
    compress nogap  s(N r2  F)  ///
          star(* 0.1 ** 0.05 *** 0.01) b(%6.4f)
		  
		  
* Kyoto protocol and Doha amendment
	* figure3 
twoway   ( scatter env38 wbgi_gee if sign ==1 , msymbol(T) color(maroon) msize(0.5)) ///
		  ( qfit env38 wbgi_gee if sign ==1 ,color(red) ) ///
		( scatter env38 wbgi_gee if sign !=1 ,msymbol(o) msize(0.5) color(gray)) ///
	    (qfit env38 wbgi_gee if sign !=1 ,color(blue) ) 
		
set scheme s2mono
twoway   ( scatter env38 wbgi_gee if sign ==1 , msymbol(T)  msize(0.5)) ///
		  ( qfit env38 wbgi_gee if sign ==1  ) 
		  
twoway ( scatter env38 wbgi_gee if sign !=1 ,msymbol(o) msize(0.5)) ///
	    (qfit env38 wbgi_gee if sign !=1  ) 
	
	*table 5
	gen gee2=wbgi_gee^2
	local varlist "eco7w indus eco13 eco1 city15 env65  env59 env93 yr_sch_sec "
reg env38 wbgi_gee gee2 `varlist' if sign==1  // 240 95-14
est store did1
reg env38 wbgi_gee gee2 `varlist' if sign!=1   // 240 95-14
est store did2
xtreg env38 wbgi_gee gee2 `varlist'  if sign==1,fe   // 240 95-14
est store did3
xtreg env38 wbgi_gee gee2  `varlist' if sign!=1,fe    // 240 95-14
est store did4

esttab did1  did2 did3 did4 ,compress nogap  s(N r2  F ) ///
          star(* 0.1 ** 0.05 *** 0.01)   b(%6.4f)
		  
	* figure4
	drop if (year < 1995 | year > 2015)
	bysort year: egen env38m=mean(env38)	if sign == 1
bysort year: egen env38n=mean(env38) if sign!=1
twoway (line env38m year) (line env38n year),xline(2002)
		drop env38r env38s
bysort year: egen env38r=mean(env38)	if doha == 1
bysort year: egen env38s=mean(env38) if doha!=1		  
		  
twoway (line env38r year) (line env38s year),xline(2008) xline(1998)

set scheme s2mono
twoway   ( scatter env38 wbgi_gee if doha ==1 , msymbol(T)  msize(0.5)) ///
		  ( qfit env38 wbgi_gee if doha ==1  ) 
		  
twoway ( scatter env38 wbgi_gee if doha !=1 ,msymbol(o) msize(0.5)) ///
	    (qfit env38 wbgi_gee if doha !=1  )

	* table6 
	replace doha =0 if doha !=1
		  gen inter3=doha*wbgi_gee
		  local varlist "eco7w eco13 eco1 city15 env65 env24 env59 env93 yr_sch_sec hf_efiscore"
reg env38 wbgi_gee  doha ,nocons // 115 96-14
est store s1	  
reg env38 wbgi_gee  doha inter3 ,nocons // 115 96-14
est store s2	
xtreg env38 wbgi_gee doha `varlist' ,mle nocons // 115 96-14
est store s3	  
xtreg env38 wbgi_gee doha inter3 `varlist' ,mle nocons // 115 96-14
est store s4	  
	esttab s1 s2 s3 s4 ,compress nogap  s(N r2  F ) ///
          star(* 0.1 ** 0.05 *** 0.01)    
		  	
	
		  
*不同收入国家散点图 
twoway ( scatter env38 wbgi_gee if incomelev2 ==1 ,msize(0.2) color(maroon) ) (qfit env38 wbgi_gee if incomelev2 ==1 ,color(red)) ( scatter env38 wbgi_gee if incomelev2 !=1 ,msize(0.2) color(  gray  ))(qfit env38 wbgi_gee if incomelev2 !=1 ,color(blue))

	*平行趋势1 Kyoto protocol
	drop if (year < 1995 | year > 2015)
	bysort year: egen env38m=mean(env38)	if sign == 1
bysort year: egen env38n=mean(env38) if sign!=1
twoway (line env38m year) (line env38n year),xline(2002)
	*平行趋势2 Doha amendment
	drop env38r env38s
bysort year: egen env38r=mean(env38)	if doha == 1
bysort year: egen env38s=mean(env38) if doha!=1		  
		  
twoway (line env38r year) (line env38s year),xline(2008) xline(1998)	

